#pragma once

#include <stack>

#include "Singleton.h"
#include "WinMutex.h"
#include <SFML\Network.hpp>
#include "Packet.h"
#include "WinThread.h"
#include "GameState.h"
#include "PlayerNetwork.h"

class DataBase : public Singleton<DataBase>
{
	friend class Singleton<DataBase>;
	
private:
	DataBase(void);
	~DataBase(void);

	PlayerNetwork					m_currentPlayer;
	WinMutex						m_mutexCurrentPlayer;

	std::vector<PlayerNetwork>		m_players;
	WinMutex						m_mutexPlayers;

	GameState						m_state;
	WinMutex						m_mutexState;

	int								m_numberPlayer;
	WinMutex						m_mutexNumberPlayer;

	std::string						m_ip;
	WinMutex						m_mutexIp;

	int								m_port;
	WinMutex						m_mutexPort;
	
public:
	void							initDatabase();

	//PLAYER
	void							setCurrentPlayer(PlayerNetwork);
	PlayerNetwork					getCurrentPlayer();					

	//CLIENTS
	void							pushBackPlayer(PlayerNetwork);
	void							erasePlayerNumber(int);
	int								getSizePlayer();
	PlayerNetwork					getElementAt(int);
	void							modifyPlayer(PlayerNetwork);
		
	//STATE
	GameState						getCurrentState();
	void							setState(GameState);

	//Player
	int								getNumberPlayer();
	void							setNumberPlayer(int);

	//IP
	std::string						getIp();
	void							setIp(std::string);

	//Port
	int								getPort();
	void							setPort(int);
};